package com.hogan.hoganproject.settings;

import android.app.Application;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelProviders;

import com.hogan.hoganproject.R;
import com.hogan.hoganproject.base.app.HoganApplication;
import com.hogan.hoganproject.base.fragment.BaseFragment;
import com.hogan.hoganproject.base.mvp.BasePresenter;

/**
 * Author: chenhu
 * Time: 2020/9/3 11:26
 * Description do somethings
 */
public class SettingsFragment extends BaseFragment {
    private TextView mTextView;

    public static SettingsFragment newInstance() {
        Bundle args = new Bundle();
        SettingsFragment fragment = new SettingsFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public int getLayoutResID() {
        return R.layout.settings_fragment;
    }

    @Override
    protected BasePresenter initPresenter() {
        return null;
    }

    @Override
    protected void initView() {

        //  HoganViewModel hoganViewModel = ViewModelProvider.AndroidViewModelFactory.getInstance(HoganApplication.getInstance()).create(HoganViewModel.class);
        //  hoganViewModel  =new ViewModelProvider(requireActivity()).get(HoganViewModel.class);

        HoganViewModel hoganViewModel = ViewModelProviders.of(requireActivity()).get(HoganViewModel.class);
        mTextView = mBaseView.findViewById(R.id.setting_add_tv);

        //   HoganViewModel hoganViewModel = new HoganViewModel(2);
        mTextView.setOnClickListener(v -> {
          //  mTextView.setText(hoganViewModel.index + "");
        });

    }

    @Override
    public void onUnsubscribe() {
        if (mFragmentPresenter != null) {
            mFragmentPresenter.onDetach();
        }
    }

    @Override
    public void onRecoverLoadData() {

    }

    class HoganViewModel extends ViewModel {

        public MutableLiveData<Integer> itemALive = new MutableLiveData();

    }

}
